package com.linedata.acq.service.impl;

import java.io.Serializable;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.linedata.acq.dao.IDao;
import com.linedata.acq.exception.ServiceSecurityException;
import com.linedata.acq.service.ICommonService;

/**
 * Base class for Business Services - use this class for utility methods and
 * generic CRUD methods.
 * 
 */
public class ServiceImpl<T> implements ICommonService<T> {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 3542152567633805667L;
	protected IDao	dao	= null;

	public void setDao(IDao _dao) {
		this.dao = _dao;
	}
 
	public IDao getDao() {
		return dao;
	}

	public List<T> fetch() {
		return dao.findAll();
	}

	public int count() {
		return dao.count();
	}

	public void remove(T _id) {
		dao.delete(_id);
	}

	public T add(T _o) {
		return (T) dao.add(_o);
	}

	public T save(T _o) {
		return (T) dao.save(_o);
	}

	public Class<T> getType() {
		return getDao().getType();
	}

	public List<T> findRestrictedList(int startPosition, int nbElements, String orderBy, String orderSens) {
		return dao.findRestrictedList(startPosition, nbElements, orderBy, orderSens);
	}

	public List<T> getListControlByObject(T objet) throws ServiceSecurityException {
		// TODO Auto-generated method stub
		return null;
	}

	public T findById(Serializable id) {
		System.out.println("****************************744554");
		return null;
	}

	public T AfficherLibelle(int id) throws ServiceSecurityException {
		
		return (T) dao.afficher(id);
	}
}
